<%-- 
    Document   : setExercises
    Created on : 08.02.2011, 15:54:56
    Author     : eric
--%>

<%@ page contentType="text/html" pageEncoding="UTF-8" %>
<%@ include file="header.jsp" %>
<%@ page import="java.util.*" %>
 <div id="contents">
     <h1>Neue Übung eingeben</h1>

     <form action="writeExerciseToDb.jsp" method="post">
        <fieldset>
            <legend>Übung</legend>
            <input type="hidden" name="hidden" value="0">
            <input type="hidden" name="popularity" value="0">

            <label>Name der Übung*</label>
            <input type="text" name="name" size="20" value="<% if(request.getParameterMap().containsKey("name")) out.print(request.getParameter("name")); %>">

            <br/><br/>
            <label>Kategorie</label>

            <select name="category">
            <%
                // Alle Kategorien laden
                String[][] cat = db.categories.getCategorieNamesAndIdsByTypeofsport(session.getAttribute("typeofsport").toString());

                // Für jede Kategorie ...
                for (String value[]: cat){
                    // Erstelle ein option-Element
                    out.print("<option value=\"" + value[0] + "\"");
                    if(request.getParameterMap().containsKey("category")){
                        if(request.getParameter("category").equals(value[0])){
                            out.print(" selected");
                        }
                    }
                    out.print(">" + value[1] + "</option>" );
                }
            %>
            </select>

            <br/><br/>

            <label>Schwierigkeitsgrad</label>

            <select name="rating" size="1">
                <option value="0">Bitte auswählen</option>
                <%
                    // option-Element mit Werten von 1 - 9 erstellen
                    for(int i=1;i<10;i++){
                        out.print("<option value=\"" + i + "\"");
                        if(request.getParameterMap().containsKey("rating")){
                            if(request.getParameter("rating").equals("" + i)){
                                out.print(" selected");
                            }
                        }
                        out.print(">" + i + "</option>");
                    }
                %>
            </select>

            <br/><br/>

            <label>Ablauf</label>
            <textarea name="procedure" cols="40" rows="5"><% if(request.getParameterMap().containsKey("procedure")) out.print(request.getParameter("procedure")); %></textarea>

            <br/><br/>
            <label>Notizen*</label>
            <textarea name="notes" cols="40" rows="5"><% if(request.getParameterMap().containsKey("notes")) out.print(request.getParameter("notes")); %></textarea>

            <br/><br/>
            <label>Teilnehmer Min</label>
            <input type="text" name="partMin" size="2" value="<% if(request.getParameterMap().containsKey("partMin")) out.print(request.getParameter("partMin")); %>">

            <br/><br/>
            <label>Teilnehmer Max</label>
            <input type="text" name="partMax" size="2" value="<% if(request.getParameterMap().containsKey("partMax")) out.print(request.getParameter("partMax")); %>">

            <br/><br/>
            <label>Übungs Aufbau</label>
            <textarea name="buildup" cols="40" rows="5"><% if(request.getParameterMap().containsKey("buildup")) out.print(request.getParameter("buildup")); %></textarea>

            <br/><br/>
            <label>benötigte Hilfsmittel*</label>
            <textarea name="tools" cols="40" rows="3"><% if(request.getParameterMap().containsKey("tools")) out.print(request.getParameter("tools")); %></textarea>

            <br/><br/>
            <label>Übungsdauer*</label>

            <select name="duration" size="1">
                <%
                    // Dauer von 5 - 60 Minuten erstellen
                    for(int i = 5;i<65;i=i+5){
                        out.print("<option value=\"" + i + "\"");
                        if(request.getParameterMap().containsKey("duration")){
                            if(request.getParameter("duration").equals("" + i)){
                                out.print(" selected");
                            }
                        }
                        out.print(">"+ i +" Minuten</option>");
                    }
                %>
            </select>

            <br/><br/>

            <label>Übungsziel*</label>
            <textarea name="aim" cols="40" rows="5"><% if(request.getParameterMap().containsKey("aim")) out.print(request.getParameter("aim")); %></textarea>

            <br/><br/>

            * Pflichtfeld

            <br/><br/>

            <input class="submit" type="submit" name="send" value="Übung erstellen">
                     
        </fieldset>
    </form>
</div>

<%@ include file="footer.jsp" %>